﻿using System;
using System.Threading.Tasks;

namespace Hopscotch.Presentation.Common.Threading
{
    public interface IDispatcher
    {
        /// <summary>
        /// Unique Id for the dispatcher thread
        /// </summary>
        int ThreadId { get; }

        /// <summary>
        /// Thread Name
        /// </summary>
        string ThreadName { get; }

        /// <summary>
        /// Determines whether the calling thread is the thread associated with this dispatcher
        /// </summary>
        bool CheckAccess();

        /// <summary>
        /// Invoke action on the UI thread
        /// </summary>
        void Invoke(Action method);

        /// <summary>
        /// Dispatch action to the UI thread queue
        /// </summary>
        Task RunAsync(Action method);

    }
}
